const cloud = require('wx-server-sdk')
cloud.init({
    env: cloud.DYNAMIC_CURRENT_ENV
})
// 云函数入口函数
exports.main = async (event, context) => {
    const db = cloud.database()
    const res = await db.collection('rss_subscribe').get()
    console.log('subscribe', res)
    const { data } = res
    //  console.log('定时器触发1')
    // let res = await cloud.callFunction({
    //     name: 'syncRss',
    //     data: {
    //         rssUrl: list[0]
    //     },
    //     config: {
    //         env: 'dev-d62e0'
    //     }
    // })
    // console.log('定时器触发2', res)
    for (let i = 0; i < data.length; i++) {
        let rssUrl = data[i].url
        await cloud.callFunction({
            name: 'syncRss',
            data: {
                rssUrl
            }
        });
        // console.log("更新",rssUrl)
      
    }

}